tools/hotplug/Linux: force release lock if holder process is gone (fix)
authorKouya Shimura <kouya@jp.fujitsu.com>
Wed, 15 Dec 2010 16:49:06 +0000 (16:49 +0000)
committerKouya Shimura <kouya@jp.fujitsu.com>
Wed, 15 Dec 2010 16:49:06 +0000 (16:49 +0000)
22508:57907b28e51a was unsafe for mutual exclusion.  There is a case
that the owner file doesn't exist yet when an atomic mkdir operation
fails.

Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/hotplug/Linux/locking.sh

index 8748d95454b6b053e711deee76c318f1ac3de2cd..e233c4763a34704b7f061497b2ae32064d74585f 100644 (file)
@@ -63,7 +63,7 @@ _claim_lock()
       retries=0
     else
       local pid=$(echo $owner | cut -d : -f 1)
-      if [ ! -f "/proc/$pid/status" ]
+      if [ -n "$pid" -a "$pid" != "unknown" -a ! -f "/proc/$pid/status" ]
       then
         _release_lock $lockdir
       fi